<?php
// +----------------------------------------------------------------------
// | Bwsaas
// +----------------------------------------------------------------------
// | Copyright (c) 2015~2020 http://www.buwangyun.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Gitee ( https://gitee.com/buwangyun/bwsaas )
// +----------------------------------------------------------------------
// | Author: buwangyun <hnlg666@163.com>
// +----------------------------------------------------------------------
// | Date: 2020-9-28 10:55:00
// +----------------------------------------------------------------------

namespace app\common\model;

use buwang\base\BaseModel;

class MemberForm extends BaseModel
{

    protected $pk = 'id';

    /**
     * @param int $miniapp_id
     * @param $uid
     */
    public static function getForm(int $miniapp_id, $uid)
    {
        return self::where(['member_miniapp_id' => $miniapp_id, 'uid' => $uid, 'is_del' => 0])->whereTime('create_time', '-7 day')->find();
    }

    /**
     * 增加FormID
     * @param integer $miniapp_id
     * @param integer $uid
     * @param string $form_id
     * @return void
     */
    public static function addForm(int $miniapp_id, int $uid, $form_id)
    {
        $data['member_miniapp_id'] = $miniapp_id;
        $data['form_id'] = $form_id;
        $data['uid'] = $uid;
        $data['is_del'] = 0;
        $data['create_time'] = time();
        return self::insert($data);
    }
}